var ws, uid,order_id,member_id,goods_id;
var f_id = 1;
document.addEventListener('plusready', function() {
	ws = plus.webview.currentWebview();
	cid = ws.c_id;
	tid = ws.t_id;
	member_id = plus.storage.getItem('id');
	ele = document.querySelector('[ng-controller=circleController]');
	$scope = angular.element(ele).scope();
	$scope.initView(cid,tid,member_id);
	$scope.$apply();
})
 
var app = angular.module("App", []);
app.controller('circleController', function($scope, $http) {
	$scope.goReply = function(cid,tid,rid){
		console.log(cid+'--'+tid+'--'+rid);
		gotoreply(cid, tid,rid);
	}
	$scope.initView = function(cid,tid, member_id) { 
		console.log(circle + "/index.php?act=theme&op=mobile_theme_detail&c_id="+ cid +"&t_id=" + tid + "&u_id=" + member_id);
		$http.get(circle + "/index.php?act=theme&op=mobile_theme_detail&c_id="+ cid +"&t_id=" + tid + "&u_id=" + member_id)
			.success(function(response) {
				console.log(JSON.stringify(response.circle_theme));
				$scope.info = response.circle_theme;
				$scope.circle_id = response.circle_theme.circle_id;
				$scope.theme_id = response.circle_theme.theme_id;
				$scope.affixs = response.affix_list;
				$scope.replys = response.reply_info;
				$scope.theme_onlike = response.theme_onlike;
				if(!$scope.theme_onlike) { //1可以赞  0不可以
					$('.like').on('click', function() { 
						likeNo($('.like'), { t_id: $(this).attr('t_id'), c_id: $(this).attr('c_id'), u_id: member_id });
					}) 
				} else { 
					$('.like').on('click', function() {
						if(!member_id) {
							console.log(member_id);
							mui.toast("请先登录");
							openNewPage("login.html");
						} else {
							likeYes($('.like'), { t_id: $(this).attr('t_id'), c_id: $(this).attr('c_id'), u_id: member_id });
						}

					})
				}
				
				//跳转到评论
				$(".Friends").on('click', function() {
					gotoreply(response.circle_theme.circle_id, response.circle_theme.theme_id,0);
				});

//				console.log(response);
			})
	}

})